// The list template implementation for xort

template <typename T>
struct listContainer
{
    T    m_Item;
    listContainer m_Prev;
    listContainer m_Next;
        
    // for push back
    void initPushBack( listContainer Prev, T Item ) {
            m_Item = Item;
            m_Prev = Prev; m_Next = NULL;
            if( Prev ) Prev.m_Next = self;
    }
        
    // for push front
    void initPushBack( T Item, listContainer Next ) {
            m_Item = Item;
            m_Prev = NULL; m_Next = Next;
            if( Next ) Next.m_Prev = self;
    }

    void inverse_to_begin( listContainer Prev ) {
            if( m_Prev ) m_Prev.inverse_to_begin( self );
            m_Next = m_Prev; m_Prev = Prev;
    }
}

struct listIterator
{
    Symbol next();
    Symbol prev();
}

template <typename T> 
struct list
{
    dword    size();
    void     push_front( T item );
    void     push_back( T item );
    void     pop_front();
    void     pop_back();
    T        top();
    void     clear();
    void     reset_to_begin();
    T        next();
    void     reset_to_end();
    T        prev();
}


    dword storeByte( byte b )
    byte getByte( dword dwAtIndex )
    dword storeShort( short s )
    short getShort( dword dwAtIndex )
    dword storeWord( word w )
    word getWord( dword dwAtIndex )
    dword storeInt( int i )
    int   getInt( dword dwAtIndex )
    dword storeDword( dword d )
    dword getDword( dword dwAtIndex )
    dword storeLong( qlong l )
    qlong getLong( dword dwAtIndex )
    dword storeQword( qword q )
    qword getQword( dword dwAtIndex )
    dword storeFloat( float f )
    float getFloat( dword dwAtIndex )
    dword storeDouble( double r )
    double getDouble( dword dwAtIndex )
    dword storePointer( void *p )
    void* getPointer( dword dwAtIndex )
